/*
package com.noah.note.presenter;

import com.noah.note.R;
import com.noah.note.bean.Reply;
import com.noah.note.bean.ReplyNote;
import com.noah.note.global.BasePresenter;
import com.noah.note.global.Const;
import com.noah.note.manager.JsonManager;
import com.noah.note.model.HomeModel;
import com.noah.note.utils.LogUtils;
import com.noah.note.utils.NetUtils;
import com.noah.note.utils.ToastUtils;
import com.noah.note.view.HomeView;

import java.io.IOException;
import java.util.ArrayList;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

public class HomePresenter extends BasePresenter<HomeView> {
    HomeModel model;

    public HomePresenter() {
        model = new HomeModel();
    }

    public void getNoteList(long bid, long time) {
        if (!NetUtils.isConnected()) {//无网络
            ToastUtils.show(R.string.failure_network);
            return;
        }
        model.getNoteList(bid, time, new Callback() {
            // 请求失败的回调
            @Override
            public void onFailure(Call call, IOException e) {
                e.printStackTrace();
                ToastUtils.show(R.string.failure_gain);
            }

            // 请求成功的回调
            @Override
            public void onResponse(Call call, Response response) throws IOException {
                // 将response转化成String
                String responseStr = response.body().string();
                LogUtils.i("responseStr = " + responseStr);
                Reply reply = JsonManager.getInstance().toBean(responseStr, Reply.class);
                int code = reply.getCode();
                ToastUtils.show(reply.getMsg());
                if (code == Const.SUCCESS) {//登录成功
                    String data = reply.getData();
                    ArrayList<ReplyNote> replyNotes = (ArrayList<ReplyNote>) JsonManager.getInstance().toBeanList(data, ReplyNote.class);
                    LogUtils.i(replyNotes.toString());
                    if (getView() != null) {
                        getView().noteListSuccess(replyNotes);
                    }
                }
            }
        });
    }
}
*/
